<header id="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="<%= window.location.href %>">活动数据汇总</a>
            </li>
        </ol>
    </div>
</header>
<section id="content">
    <div class="panel">
        <form class="form-horizontal" role="form" id="searchBox">
            <div class="form-group">
                <div class="col-md-11">
                    <label for="dateFilter" class="col-md-1 control-label">日期：</label>
                    <div class="col-md-5">
                        <input type="text" id="dateFilter" class="form-control text-center" value="<%= options.date_range[0] %> ~ <%= options.date_range[1] %>">
                    </div>
                    <label class="col-md-1 control-label">商品类型：</label>
                    <div class="col-md-2">
                        <select class="form-control select" data-field="goods_category" multiple>
                            <% _.each(goodsCategories, function(gc){ %>
                                <option value="<%= gc.get('id') %>" <%= options.goods_category[gc.get('id')] == null ? "" : "selected" %>> <%= gc.get('name') %> </option>
                            <% }) %>
                        </select>
                    </div>
                    <label class="col-md-1 control-label">活动类型：</label>
                    <div class="col-md-2">
                        <select class="form-control select" data-field="category" multiple>
                            <% _.each(categories, function(ca){ %>
                                <option value="<%= ca.get('id') %>" <%= options.category[ca.get('id')] == null ? "" : "selected" %>> <%= ca.get('name') %> </option>
                            <% }) %>
                        </select>
                    </div>
                    <label class="col-md-1 control-label">商品名：</label>
                    <div class="col-md-5">
                        <select class="form-control search-select" data-field="goods" multiple>
                            <% _.each(goodsList, function(g){ %>
                                <option value="<%= g.get('id') %>" <%= options.goods[g.get('id')] == null ? "" : "selected" %>> <%= g.get('name') %> </option>
                            <% }) %>
                        </select>
                    </div>
                    <label class="col-md-1 control-label">显示类型：</label>
                    <div class="col-md-2">
                        <select class="form-control select" data-field="mode" data-type="int">
                            <option value="0" <%= options.mode == 0 ? "selected" : "" %>>总值</option>
                            <option value="1" <%= options.mode == 1 ? "selected" : "" %>>均值</option>
                        </select>
                    </div>
                </div>
                <div class="col-md-1">
                    <input type="button" id="search" class="btn btn-primary btn-block form-control" value="提交">
                </div>
            </div>
        </form>
    </div>

    <div class="panel">
        <table class="table table-striped fs13" id="main-list">
            <thead>
                <tr class="bg-light">
                    <th>活动模板ID</th>
                    <th>商品名</th>
                    <th>商品类型</th>
                    <th>活动分类</th>
                    <th class="sortable" data-field="price">商品成本</th>
                    <th class="sortable" data-field="target_amount">活动价格</th>
                    <th class="sortable" data-field="real_payer_count">渠道用户购买人数</th>
                    <th class="sortable" data-field="virtual_payer_count">自有用户购买人数</th>
                    <th class="sortable" data-field="new_payer_count">新用户购买人数</th>
                    <th class="sortable" data-field="real_pay_amount">渠道用户购买金额</th>
                    <th class="sortable" data-field="virtual_pay_amount">自有用户购买金额</th>
                    <th class="sortable" data-field="new_pay_amount">新用户购买金额</th>
                    <th>开奖次数</th>
                    <th class="sortable" data-field="real_win_count">渠道用户中奖次数</th>
                    <th class="sortable" data-field="virtual_win_count">自有用户中奖次数</th>
                    <th class="sortable" data-field="new_win_count">新用户中奖次数</th>
                </tr>
            </thead>
            <tbody class="admin-form">
                <% _.each(items, function(item){ %>
                    <tr>
                        <td><a href="#op/template/<%= item._id %>/"><%= item._id %></a></td>
                        <td><%= item.name %></td>
                        <td><%= item.goods_category ? goodsCategoryCollection.get(item.goods_category).get('name') : '-' %></td>
                        <td><%= item.category_id ? categoryCollection.get(item.category_id).get('name') : '-' %></td>
                        <td><%= item.price.toFixed(2) %></td>
                        <td><%= item.target_amount %></td>
                        <td><%= item.real_payer_count %></td>
                        <td><%= item.virtual_payer_count %></td>
                        <td><%= item.new_payer_count %></td>
                        <td><%= item.real_pay_amount %></td>
                        <td><%= item.virtual_pay_amount %></td>
                        <td><%= item.new_pay_amount %></td>
                        <td><%= item.virtual_win_count + item.real_win_count %></td>
                        <td><%= item.real_win_count %></td>
                        <td><%= item.virtual_win_count %></td>
                        <td><%= item.new_win_count %></td>
                    </tr>
                <% }) %>
            </tbody>
        </table>
    </div>
</section>
